﻿CREATE TABLE spm.SsasMeasureGroup
(
	/*
	 * Table to support the SSAS Partition Manager.  See https://SSASPartitionManager.codeplex.com/documentation for documentation.
     *
	 * Part of the SSAS Partition Manager sample code which can be downloaded from https://SSASPartitionManager.codeplex.com/
	 * 
	 * Written by Dr. John Tunnicliffe, independent business intelligence consultant
	 * Available for consultancy assignments and speaking engagements
     * 	
	 * eMail: john@decision-analytics.co.uk 
	 * http://www.decision-analytics.co.uk/
	 * http://www.sqlbits.com/Speakers/Dr_John_Tunnicliffe
	 * https://www.linkedin.com/in/drjohntunnicliffe
	 */
	SsasMeasureGroupKey INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
	SsasMeasureGroupName nvarchar(50) NOT NULL,  -- the name of the measure group
	PartitionPeriod nchar(1) NOT NULL default('M'), -- default to monthly
	PartitionStartDate date not null default('20110101'),  -- date the first partition period should start
	PartitionSliceIsRange bit not null default(0),
	DateColumnName nvarchar(30) NOT NULL,
	DateColumnDataType nvarchar(20) NOT NULL default('int'),
	SsasCubeKey INT NOT NULL, 
	CONSTRAINT [FK_MeasureGroup_OlapCube] FOREIGN KEY (SsasCubeKey) REFERENCES spm.SsasCube(SsasCubeKey), 
    CONSTRAINT [CK_SsasMeasureGroup_DateColumnDataType] CHECK (DateColumnDataType in (N'int',N'date',N'datetime')), 
    CONSTRAINT [CK_SsasMeasureGroup_DateColumnName] CHECK (len(DateColumnName)>0),
);
GO
